<table class="layui-table">
    <colgroup>
        <col width="20%">
        <col width="30%">
        <col width="20%">
        <col width="30%">
    </colgroup>
    <tbody>
        <tr>
            <td>必选参数</td>
            <td class="must_request_params" colspan="3"></td>
        </tr>
         <tr>
            <td>所有参数</td>
            <td class="all_request_params" colspan="3"></td>
        </tr>
        <tr>
            <td>请求方式</td>
            <td class="request_type"></td>
            <td>请求是否成功</td>
            <td  class="request_result"></td>
        </tr>
        <tr>
            <td>返回值</td>
            <td class="request_responseParams" colspan="3"></td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
  var interface_info = KgoUtil.getState("TestInterfaceParam");
  var test_url =  KgoUtil.getState("RootURL");
  var method_type =interface_info.methodType;
  var request_params =interface_info.params ? interface_info.params:'[]';
  var _MustRequestParams = {};
  var _AllRequestParams = {};
  /**
  * 初始化请求
  */
  function initRequst(){

    $.each(JSON.parse(request_params),function(index,item){
      if(item.isMust=='yes'){
        _MustRequestParams[item.name]=item.defaultValue == "无" ? "" : item.defaultValue;
      }
      _AllRequestParams[item.name]=item.defaultValue == "无" ? "" : item.defaultValue;
    });


    $('.must_request_params').html('<pre>' +formatJson(_MustRequestParams) + '<pre/>');
    $('.all_request_params').html('<pre>' +formatJson(_AllRequestParams) + '<pre/>');

    $('.request_type').html('<span style="color:#009688;font-weight:600;">'+method_type+'</span>')
  }
  function requestAjax(){
      $.ajax({
          url: test_url+interface_info.url,
          type:method_type,
          dataType:'text',
          success: function(data){
            $('.request_result').html('<span style="color:#5FB878;font-weight:600;">请求成功</span>');
            var jsonFormat = formatJson(data);

            $('.request_responseParams').html('<pre>' +jsonFormat + '<pre/>');

          },
          error:function(error){
              $('.request_result').html('<span style="color:#FF5722;font-weight:600;">请求失败</span>');
          }
      });
  }
  $(function() {
      initRequst();
      requestAjax();
  });
</script>
<style>
.must_request_params{
  height:140px;
}
.all_request_params{
  height:240px;
}
.request_responseParams{
  height:240px;
}
</style>
